package com.alliky.controller;

import com.alliky.common.ServerResponse;
import com.alliky.pojo.Users;
import com.alliky.service.IUserService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户相关API
 */
@RestController
@RequestMapping("user")
public class UserController {

    @Autowired
    IUserService iUserService;

    @PostMapping("/login")
    public ServerResponse<Users> login(@RequestParam String username, @RequestParam String password){
        if (StringUtils.isBlank(username)||StringUtils.isBlank(password)){
            return ServerResponse.createByErrorMessage("用户名或密码不能为空");
        }
        return iUserService.login(username,password);
    }
}
